<?php
 require_once("../include/httpclient.php");
 require_once("../include/db_mysql.php");
/*serviceurl:102
根据industryId返回party数组
$arg:industryid
*/
function GetPartyArrayByIndustryId($arg)
{

	$industryId = $arg['industryId'];
	$landmarkId = $arg['landmarkId'];
	$link = new SqlClass();
	//连接数据库
	$link->connect();
	//执行sql语句
	$return = array();
	$partyIdArray=array();	
    $sqlCommand1 = "select partyId from partyindustry where industryId = $industryId";		
	$rs1 = $link->exec_sql($sqlCommand1);
	while($row1=mysql_fetch_array($rs1))
	{		
		$array = array();
		$array['facilityId'] = array();
		$partyId = $row1['partyId'];       
		
        $sqlCommand5="select distance from partylandmarkdistance where partyId = $partyId and landmarkId=$landmarkId";
		$rs5 = $link->exec_sql($sqlCommand5);   
		if($row5=mysql_fetch_array($rs5))
		{				
			$array['distance'] = $row5['distance'];
		}
		else
		{
			$array['distance'] = -1;
		}				
		$sqlCommand2 = "select facilityId from partyfacility where partyId = $partyId";
        $rs2= $link->exec_sql($sqlCommand2);
		while($row2=mysql_fetch_array($rs2))
		{
          array_push($array['facilityId'],$row2['facilityId']);         
		}         		
		$sqlCommand3 = "select partyId,partyName,homePageId from party where partyId = $partyId";
		$rs3 = $link->exec_sql($sqlCommand3);	
		while($row3=mysql_fetch_array($rs3))
		{	 				
			$array['partyName']=$row3['partyName'];
			$homePageId = $row3['homePageId'];
			$sqlCommand4 = "select pageUrl,message from partypageinfo where pageId = $homePageId";
			$rs4 = $link->exec_sql($sqlCommand4);	
			while($row4 = mysql_fetch_array($rs4))
			{
				$array['pageUrl']=$row4['pageUrl'];				
				$array['message']=$row4['message'];		
				break;
			}			
		}
			array_push($return ,$array);	
	}
	$link->close(); 
	return json_encode($return);
}

?>